/*
 * @Author: your name
 * @Date: 2021-07-15 15:04:50
 * @LastEditTime: 2021-07-26 21:39:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \usp-osm-frondend\src\api\product.js
 */
import { service } from '@/utils/request'

const api = {
  productList: '/admin/mdse/product/list',
  putOnOff: '/admin/mdse/spu/put-on-off',
  updateSort: '/admin/mdse/spu/update-sort',
  relationProduct: '/admin/mdse/product-recommend/getSpuRecommend',
  getRelationIdList: '/admin/mdse/product-recommend/recommend-list',
  saveProduct: '/admin/mdse/product/save',
  uploadImg: '/admin/upload/uploadFile',
  catalogTree: '/admin/mdse/catalog/getTreeCatalog',
  frontCatalog: '/admin/mdse/category/getTreeCategory',
  catalogById: '/admin/mdse/catalog/get',
  skuDetail: '/admin/mdse/sku',
  spuDetail: '/admin/mdse/spu',
  deleteRelation: '/admin/mdse/product-recommend/delete',
  relationSort: '/admin/mdse/product-recommend/update',
  submitRelation: '/admin/mdse/product-recommend/save',
  refundList: '/admin/order/refund/pageList',
  refundDetails: '/admin/order/refund/selectDetail',
  returenOrder: '/admin/order/return/selectLists',
  approvalRefund: '/admin/order/refund/approval',
  checkRemark: '/admin/order/orderOperationAuditRecord/selectList',
  returnDetails: '/admin/order/return/selectDetail',
  operationImages: '/admin/order/orderOperationimages/selectList',
  approvalReturn: '/admin/order/return/approval',
  getReceivingInfo: '/admin/order/orderReturnItemsReceipt/selectList',
  agreeToRefundDetail: '/admin/order/refund/agreeToRefundDetail'
}

export function productList (data) {
  return service({
    url: api.productList,
    method: 'post',
    data
  })
}

export function putOnOff (data) {
  return service({
    url: api.putOnOff,
    method: 'post',
    data
  })
}

export function updateSort (data) {
  return service({
    url: api.updateSort,
    method: 'post',
    data
  })
}

export function relationSort (data) {
  return service({
    url: api.relationSort,
    method: 'post',
    data
  })
}

export function relationProduct (data) {
  return service({
    url: api.relationProduct,
    method: 'post',
    data
  })
}

export function getRelationIdList (id) {
  return service({
    url: api.getRelationIdList + `/${id}`,
    method: 'get'
  })
}

export function deleteRelation (data) {
  return service({
    url: api.deleteRelation,
    method: 'post',
    data
  })
}

export function addProduct (data) {
  return service({
    url: api.saveProduct,
    method: 'post',
    data
  })
}

export function submitRelation (data) {
  return service({
    url: api.submitRelation,
    method: 'post',
    data
  })
}

export function uploadFile (data) {
  return service({
    url: api.uploadImg,
    method: 'post',
    data
  })
}

export function refundList (data) {
  return service({
    url: api.refundList,
    method: 'post',
    data
  })
}

// 获取后台类目
export function getTree () {
  return service({
    url: api.catalogTree,
    method: 'get'
  })
}

// 获取前台类目
export function getFrontCatalog (id) {
  return service({
    url: api.catalogById + `/${id}`,
    method: 'get'
  })
}

// 根据id获取后台类目catalogById
export function getCatalogById (channelCode) {
  return service({
    url: api.frontCatalog + `/${channelCode}`,
    method: 'get'
  })
}

export function getSkuById (id) {
  return service({
    url: api.skuDetail + `/${id}`,
    method: 'get'
  })
}

export function getSpuById (id) {
  return service({
    url: api.spuDetail + `/${id}`,
    method: 'get'
  })
}

// productSave  saveProduct
export function productSave (data) {
  return service({
    url: api.saveProduct,
    method: 'post',
    data
  })
}

export function refundDetails (data) {
  return service({
    url: api.refundDetails,
    method: 'post',
    data
  })
}

export function returenOrder (data) {
  return service({
    url: api.returenOrder,
    method: 'post',
    data
  })
}

export function approvalRefund (data) {
  return service({
    url: api.approvalRefund,
    method: 'post',
    data
  })
}

export function checkRemark (data) {
  return service({
    url: api.checkRemark,
    method: 'post',
    data
  })
}

export function returnDetails (data) {
  return service({
    url: api.returnDetails,
    method: 'post',
    data
  })
}

export function operationImages (data) {
  return service({
    url: api.operationImages,
    method: 'post',
    data
  })
}

export function approvalReturn (data) {
  return service({
    url: api.approvalReturn,
    method: 'post',
    data
  })
}

export function getReceivingInfo (data) {
  return service({
    url: api.getReceivingInfo,
    method: 'post',
    data
  })
}

export function agreeToRefundDetail (data) {
  return service({
    url: api.agreeToRefundDetail,
    method: 'post',
    data
  })
}
